<?php
class GetNew extends CI_Controller
{
	public function __construct()
	{
		parent::__construct();
		$this->load->model('getnew_model');//牛人信息
		$this->load->model('newcenter_model');
		$this->load->library('session');
		$_SESSION['wechat'] = 'fdhsaiuhfihi1232';
		$_SESSION['wechat_nick'] = 'Alex隆';
		$_SESSION['avatar'] = 'http://liveser.cn/img/ry1.jpeg';
		$data = array();
		if(isset($_SESSION['wechat']))
		{
			$_SESSION['id'] = $this->getnew_model->getUserId();
			$_SESSION['phone'] = $this->newcenter_model->getPhone();
		}
		else
		{
			exit('非法访问，请从微信进入');
		}

	}
	public function index()	
	{
		$data = array();
		$data['school'] = array('ECNU','SJTU');
		//$data['getnews'] = $this->getnew_model->getgetnews();
		$this->load->view('new_getnew/index',$data);
	}

	public function zan()
	{
		$id = $this->input->post('id');
		$result = $this->getnew_model->addZan($id);
		echo json_encode(array("id"=>$id,"amount"=>$result['num']));
	}

	public function view()
	{
		$data = array();
		$data['person'] = $this->getnew_model->getPerson();
	    $data['themes'] = $this->getnew_model->getThemes();
	    $this->load->view('new_getnew/detail',$data);
	}
	
	public function getSchools()
	{
		echo json_encode(array('ECNU','SJTU'));
	}
}